package com.qing.common.utils.json.hutool;

import org.apache.commons.lang3.StringUtils;

/**
 * @author guoqf
 */
public enum DefaultConvertorEnum {
    /**
     * 等待审批人审批
     */
    NOT_APPROVED("2", "0", "待审批"),
    /**
     * 审批人同意申请
     */
    APPROVED_AGREE("0", "1", "审批通过"),
    /**
     * 审批人拒绝
     */
    APPROVED_REFUSE("1", "2", "审批拒绝"),
    /**
     * 审批失败或超时
     */
    APPROVED_FAILED("-1", "3", "审批失败或超时"),
    /**
     * 审批服务内部处理异常
     */
    APPROVED_ERROR("-2", "3", "审批服务处理异常"),
    ;


    private final String dependApprovalStatus;

    private final String openApprovalStatus;

    private final String approvalStatusDesc;

    DefaultConvertorEnum(String dependApprovalStatus, String openApprovalStatus, String approvalStatusDesc) {
        this.dependApprovalStatus = dependApprovalStatus;
        this.openApprovalStatus = openApprovalStatus;
        this.approvalStatusDesc = approvalStatusDesc;
    }

    public String getDependApprovalStatus() {
        return dependApprovalStatus;
    }

    public String getOpenApprovalStatus() {
        return openApprovalStatus;
    }

    public String getApprovalStatusDesc() {
        return approvalStatusDesc;
    }

    public static DefaultConvertorEnum fromDependStatus(String dependApprovalStatus) {
        if (StringUtils.isBlank(dependApprovalStatus)) {
            return null;
        }
        dependApprovalStatus = dependApprovalStatus.trim();
        for (DefaultConvertorEnum value : values()) {
            if (value.dependApprovalStatus.equals(dependApprovalStatus)) {
                return value;
            }
        }

        return null;
    }
}
